/****************************************************
   Author: Minh B. Do (Arizona State University)
 *****************************************************/
package edu.asu.sapa.lifted;

/**
 *  Test: The template for "Test", a (pre)condition involving
 *  a comparison related to a continuous function. Consult description
 *  for class GTest for explanation on components.
 */
public class LiftedTest {
	public int  op;
	LiftedMathForm leftSide;
	LiftedMathForm rightSide;

	public LiftedTest() {
		op = -1;
		leftSide = null;
		rightSide = null;
	}

	public LiftedTest(String c, LiftedMathForm left, LiftedMathForm right) {
		leftSide = left;
		rightSide = right;
		setOp(c);
	}

	public void setOp(String c) {
		op=-1;
		if (c.length()==2) {
			switch(c.charAt(0)) {
			case '=':
				op = 0; break;
			case '<':
				op = 2; break;
			case '>':
				op = 4; break;
			}
		} else {
			switch(c.charAt(0)) {
			case '<':
				op = 1; break;
			case '>':
				op = 3; break;
			}
		}    	
	}

	public void setLeftSide(LiftedMathForm l) {
		leftSide = l;
	}

	public LiftedMathForm getLeftSide( ) {
		return leftSide;
	}


	public void setRightSide(LiftedMathForm m) {
		rightSide = m;
	}

	public LiftedMathForm getRightSide() {
		return rightSide;
	}

	public String toString() {
		String s = "(";

		String opS="??";
		switch(op) {
		case 0:
			opS = "=="; break;
		case 1:
			opS = "<"; break;
		case 2:
			opS = "<="; break;
		case 3:
			opS = ">"; break;
		case 4:
			opS = ">="; break;
		}

		s += opS + " " + leftSide.toString() + " " +
		rightSide.toString() + ")";

		return s;
	}
}
